package com.kgc.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.kgc.dto.ModelDto;
import com.kgc.dto.Result;
import com.kgc.pojo.Model;
import com.kgc.req.ModelReq;
import com.kgc.service.ModelService;
import com.kgc.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 商品型号 前端控制器
 * </p>
 *
 * @author zsy
 * @since 2021-08-04
 */
@RestController
@RequestMapping("/api/model")
public class ModelController {

    @Autowired
    private ModelService modelService;

    /**
     * 带条件的分页查询
     * @param modelReq
     * @return
     */
    @GetMapping("search")
    public Result<Map<String, Object>> search(ModelReq modelReq){
        Map<String, Object> map = modelService.search(modelReq);
        return ResultUtils.returnDataSuccess(map);
    }

    /**
     * 查询显示图片
     * @param id
     * @return
     */
    @GetMapping("/{id}/detail")
    public Result<ModelDto> getModelDetalById(@PathVariable Long id){
        ModelDto modelDto = modelService.getModelDetalById(id);
        return ResultUtils.returnDataSuccess(modelDto);
    }

}

